ceil
Further method to sort
ceil()
function is rounded up to the closest integer.
In this example, we will apply the ceil()
function to different values:
<?php echo ( ceil ( 0.60 ) ; echo ( ceil ( 0.40 ) ; echo ( ceil ( 5 ) ; echo ( ceil ( 5.1 ) ; echo ( ceil ( - 5.1 ) ; echo ( ceil ( - 5.9 ) ) ; ?>
Try it yourself
ceil ( x )
parameter | describe |
---|---|
x | Required. A number. |
Returns the next integer not less than x , and if x has a decimal part, it will be added to one. The type returned by ceil()
is still float, because the range of float values is usually larger than integer.